import random

number=random.randint(1,10) #整数
f=random.uniform(1,100) #随机的消暑
print(round(f,2)) #保留随机小数位

l=[2,3,4,5,6,7,7,7,6,5,5,4,]
print(random.sample(l,3)) #随机取n个元素
print(random.choice(l)) #随机取1个元素
random.shuffle(l) #洗牌，没有返回值，它会改变传如list的值
print(l)

# print(string.ascii_lowercase)
# print(string.ascii_uppercase)
# print(string.digits)
# print(string.punctuation) #所有的特殊符号
# print(string.ascii_letters) #大写字母+小写字母

import string
try:
    number1=input("请输入需要的数：").strip()
except ZeroDivisionError as e:
    print(e)
except (IndentationError,EOFError):
    print("exception happened")
finally:
    print("请输入整数")
    if not number1.isdigit():
        print("process finished")
    else:
        number1=int(number1)

    def chect_name(namelist):
        return set(namelist) & set(string.ascii_letters) and set(namelist) & set(string.digits)

    def chect_password(passlist):
        return set(passlist) & set(string.ascii_lowercase) and set(passlist) & set(string.digits) and set(passlist) & set(string.ascii_uppercase) and set(passlist) & set(string.punctuation)

    count=0
    s={}
    while count<number1:
        name_list=random.sample(string.ascii_letters+string.digits,random.randint(6,12))
        if chect_name(name_list):
            username=''.join(name_list)
        else:
            continue
        pass_list=random.sample(string.ascii_letters+string.digits+string.punctuation,random.randint(8,12))

        if chect_name(pass_list):
            password=''.join(pass_list)
        else:
            continue

        s[username]=password
        count+=1
    print(s)

